package com.advertisementsystem.Mapper;


import com.advertisementsystem.entity.SysMetrics;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface SystemMetricsMapper extends BaseMapper<SysMetrics> {

    @Select("SELECT * FROM sys_metrics WHERE timestamp BETWEEN #{startTime} AND #{endTime}")
    List<SysMetrics> selectByTimeRange(@Param("startTime") LocalDateTime startTime,
                                       @Param("endTime") LocalDateTime endTime);

    @Delete("DELETE FROM sys_metrics WHERE timestamp < #{expireTime}")
    int deleteByCreateTimeBefore(@Param("expireTime") LocalDateTime expireTime);
}